<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
    <title>内嵌页面</title>
</head>
<body>
<div th:fragment="header">
    <div class="header">
        <div class="welcome fl">欢迎来到天天生鲜!</div>
        <div class="fr">
            <div class="login_info fl" th:if="${session.user != null}">
                欢迎您：<em th:text="${session.user.username}">张 山</em>
            </div>
            <div class="login_btn fl" th:if="${session.user == null}">
                <a href="login.html" th:href="@{/login}">登录</a>
                <span>|</span>
                <a href="register.html" th:href="@{/register}">注册</a>
            </div>
            <div class="user_link fl">
                <span>|</span>
                <a href="user-info.html" th:href="@{/profile}">用户中心</a>
                <span>|</span>
                <a href="cart.html" th:href="@{/cart}">我的购物车</a>
                <span>|</span>
                <a href="user-order.html" th:href="@{/order}">我的订单</a>
                <th:block th:if="${session.user != null}">
                    <span>|</span>
                    <a href="login.html" th:href="@{/logout}">退出登录</a>
                </th:block>
            </div>
        </div>
    </div>
</div>

<div th:fragment="search">
    <a href="index.html" class="logo fl" th:href="@{/index}"><img src="../static/images/logo.png"
                                                                  th:src="@{/images/logo.png}"/></a>
    <div class="search_con fl">
        <input type="text" class="input_text fl"  placeholder="搜索商品">
        <input type="button" class="input_btn fr" onclick="handleSearch()" name="" value="搜索">
    </div>
    <script>
        function handleSearch(){
            window.location.href = '/list?name=' + $('.input_text').val();
        }
    </script>
    <div class="guest_cart fr">
        <a href="cart.html" th:href="@{/cart}" class="cart_name fl">我的购物车</a>
        <div class="goods_count fl" id="show_count" th:text="${session.user != null ? session.user.cartCount : 0}">1
        </div>
    </div>
</div>

<div th:fragment="nav">
    <div class="navbar clearfix" >
        <div class="subnav_con fl">
            <h1>全部商品分类</h1>
            <span></span>
            <ul class="subnav">
                <th:block th:each="category,row : ${categories}">
                    <li><a href="#" th:href="@{/list(categoryId=${category.id})}" th:text="${category.name}">新鲜水果</a></li>
                </th:block>
            </ul>
        </div>
        <ul class="navlist fl">
            <li><a href="" th:href="@{/index}">首页</a></li>
            <li class="interval">|</li>
            <li><a href="">生鲜</a></li>
            <li class="interval">|</li>
            <li><a href="">抽奖</a></li>
        </ul>
    </div>
</div>


<div th:fragment="footer">
    <div class="foot_link">
        <a href="#">关于我们</a>
        <span>|</span>
        <a href="#">联系我们</a>
        <span>|</span>
        <a href="#">招聘人才</a>
        <span>|</span>
        <a href="#">友情链接</a>
    </div>
    <p>CopyRight © 2025 XX天天生鲜信息技术有限公司 All Rights Reserved</p>
    <p>电话：010-****888 京ICP备*******8号</p>
</div>
</body>
</html>